/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * EnvioTwitter.java
 *
 * Created on 11/01/2011, 01:49:56 PM
 */

package IGU;

import javax.swing.JFrame;
import logica.FuncionesGUI;

/**
 *
 * @author Cristian
 */
public class EnvioTwitter extends javax.swing.JFrame {

    /** Creates new form EnvioTwitter */
    public EnvioTwitter() {
        setTitle("Envio masivo de mensajes de twitter");
        initComponents();
        initMyOwnComponents();
        
    }
    
    private void initMyOwnComponents() {
        jTMensaje.setText("");
        FuncionesGUI.inicializarCombo (jCBUsuarios, "Seleccione un Usuario");
        FuncionesGUI.cargarListaUsuariosEnCombo (jCBUsuarios, false);
    
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTMensaje = new javax.swing.JTextArea();
        jTEnviar = new javax.swing.JToggleButton();
        jCBUsuarios = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(51, 51, 51));
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setIcon(new javax.swing.ImageIcon("C:\\Users\\Cristian\\Documents\\Java\\informacion\\TwitterGde.png")); // NOI18N
        jLabel1.setText("jLabel1");
        jLabel1.setName("jLabel1"); // NOI18N
        jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 11, 137, -1));

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTMensaje.setColumns(20);
        jTMensaje.setRows(5);
        jTMensaje.setName("jTMensaje"); // NOI18N
        jScrollPane1.setViewportView(jTMensaje);

        jPanel1.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(151, 138, 253, 80));

        jTEnviar.setText("Enviar");
        jTEnviar.setName("jTEnviar"); // NOI18N
        jTEnviar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTEnviarActionPerformed(evt);
            }
        });
        jPanel1.add(jTEnviar, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 230, 82, -1));

        jCBUsuarios.setName("jCBUsuarios"); // NOI18N
        jCBUsuarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCBUsuariosActionPerformed(evt);
            }
        });
        jPanel1.add(jCBUsuarios, new org.netbeans.lib.awtextra.AbsoluteConstraints(151, 84, 253, -1));

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Envío de Mensajes de Twitter");
        jLabel2.setName("jLabel2"); // NOI18N
        jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(192, 25, -1, -1));

        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Mensaje:");
        jLabel3.setName("jLabel3"); // NOI18N
        jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 120, 140, -1));

        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("Seleccione un Usuario:");
        jLabel4.setName("jLabel4"); // NOI18N
        jPanel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 60, 140, -1));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTEnviarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTEnviarActionPerformed

FuncionesGUI.EnviarMensaje(jCBUsuarios.getSelectedIndex()-1,jTMensaje.getText());

        FuncionesGUI.habilitarVentana(this.ventanaPadre, true, true);
        this.dispose();
    }//GEN-LAST:event_jTEnviarActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
FuncionesGUI.habilitarVentana(this.ventanaPadre, true, true);
        this.dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_formWindowClosing

    private void jCBUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBUsuariosActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCBUsuariosActionPerformed
private JFrame ventanaPadre;
    public JFrame getVentanaPadre()
    {
        return ventanaPadre;
    }
    public void setVentanaPadre(JFrame ventanaPadre)
    {
        this.ventanaPadre = ventanaPadre;
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new EnvioTwitter().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox jCBUsuarios;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToggleButton jTEnviar;
    private javax.swing.JTextArea jTMensaje;
    // End of variables declaration//GEN-END:variables

}
